package com.motherchild.user.service.impl;

import com.motherchild.user.dto.User;
import com.motherchild.user.dto.UserLoginDTO;
import com.motherchild.user.mapper.UserLoginMapper;
import com.motherchild.user.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhuchenxu
 * @create 2025-03-10-12:58
 */
@Service
public class UserLoginServiceImpl implements UserLoginService {
    @Autowired
    private UserLoginMapper userLoginMapper;

    @Override
    public Integer login(UserLoginDTO loginDTO) {
        String password = userLoginMapper.selectByUsername(loginDTO.getUsername());
        if (password.equals(loginDTO.getPassword())) {
            Integer id = userLoginMapper.getUserID(loginDTO.getUsername());
            return id;

        }
        return 0;
    }

    @Override
    public Integer register(User user) {
        Integer i = userLoginMapper.register(user);
        return i;
    }
}
